package com.example.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.pojo.careerTalk;
import com.example.pojo.teacher;
import com.example.pojo.tracking;
import com.example.pojo.user;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface TeacherMapper {
    //根据用户名查找管理员
    @Select("select * from teacher where username=#{username}")
    teacher findAdminFormName(String username);

    //分页展示用户信息
    @Select("select * from user")
    IPage<user> findAll(Page page);

    //分页展示就业信息
    @Select("select * from tracking")
    IPage<tracking> findAllCareerList(Page<tracking> trackingPage);

    //分页展示宣讲会信息
    @Select("select * from careertalk")
    IPage<careerTalk> findAllTalkList(Page<careerTalk> careerTalkPage);

    //查询用户信息(学号)返回page
    @Select("select * from user where Name = #{key}")
    IPage<user> findStudentById(String key,Page<user> userPage);

    //查询用户信息(学号)返回对象
    @Select("select * from user where Name =#{key}")
    user findStudentById(String key);

    //查询用户信息(姓名)
    @Select("select * from user where realname = #{key}")
    IPage<user> findStudentByName(String key,Page<user> userPage);

    //管理员端新增用户信息
    @Insert("insert into user(EducationID,MajorID,Name,realname,Gender,ContactInfo,Password,email,img)"+
            "values(#{EducationID},#{MajorID},#{name},#{realname},#{gender},#{ContactInfo},#{password},#{email},#{img})")
    void addUser(user u);

    //删除用户信息
    @Delete("delete from user where Name=#{id}")
    void deleteUser(String id);
}
